package cn.schoolwow.flow.monitor.module.common.flow;

import cn.schoolwow.ams.domain.block.list.clazz.ClazzListBlockOption;
import cn.schoolwow.ams.domain.block.list.dao.entityTable.EntityTableListBlockOption;
import cn.schoolwow.ams.module.block.listBlock.common.domain.remoteSelect.BlockRemoteSelect;
import cn.schoolwow.ams.module.block.listBlock.common.domain.remoteSelect.RemoteSelectOption;
import cn.schoolwow.quickflow.domain.FlowContext;
import cn.schoolwow.quickflow.flow.BusinessFlow;

import java.util.List;

public class AddFlowCategoryNameCascadeRemoteSelectButton implements BusinessFlow {
    @Override
    public void executeBusinessFlow(FlowContext flowContext) throws Exception {
        EntityTableListBlockOption entityTableListBlockOption = flowContext.getInstanceData(EntityTableListBlockOption.class);
        ClazzListBlockOption clazzListBlockOption = flowContext.getInstanceData(ClazzListBlockOption.class);

        flowContext.executeFlowList(new GetRemoteSelectOptionListCommonFlow());

        List<RemoteSelectOption> remoteSelectOptionList = flowContext.getData("remoteSelectOptionList", List.class);
        BlockRemoteSelect blockRemoteSelect = new BlockRemoteSelect("categoryName", "流程分类", remoteSelectOptionList);
        blockRemoteSelect.cascade = true;
        if(null!=entityTableListBlockOption){
            entityTableListBlockOption.remoteSelectList.add(blockRemoteSelect);
        }else if(null!=clazzListBlockOption){
            clazzListBlockOption.remoteSelectList.add(blockRemoteSelect);
        }
    }

    @Override
    public String name() {
        return "添加流程分类级联搜索下拉框搜索";
    }
}
